package com.wan37.logic.trading.domain.vo;

import com.wan37.protobuf.message.client2server.game.GameTrading;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : luoyong
 * @date : 2020-07-31 10:51
 **/
public class TradingVO {
    private String tradingId;
    private String senderId;
    private String receiverId;
    private int type;
    private long gold;
    private Map<String, Integer> backpackIdToCountMap;
    private long ingot;
    public TradingVO(){

    }

    public TradingVO(GameTrading.Trading trading) {
        this.tradingId = trading.getTradingId();
        this.senderId = trading.getSenderId();
        this.receiverId = trading.getReceiverId();
        this.type = trading.getType();
        this.gold = trading.getGold();
        for (GameTrading.BackpackIdToCountMap backpackIdToCountMap : trading.getBackpackIdToCountMapList()){
            if (this.backpackIdToCountMap == null){
                this.backpackIdToCountMap = new HashMap<>();
            }
            this.backpackIdToCountMap.put(backpackIdToCountMap.getBackpackId(), backpackIdToCountMap.getCount());
        }
        this.ingot = trading.getIngot();
    }
    public TradingVO(GameTrading.Trading trading, String tradingId) {
        this.tradingId = tradingId;
        this.senderId = trading.getSenderId();
        this.receiverId = trading.getReceiverId();
        this.type = trading.getType();
        this.gold = trading.getGold();
        for (GameTrading.BackpackIdToCountMap backpackIdToCountMap : trading.getBackpackIdToCountMapList()){
            if (this.backpackIdToCountMap == null){
                this.backpackIdToCountMap = new HashMap<>();
            }
            this.backpackIdToCountMap.put(backpackIdToCountMap.getBackpackId(), backpackIdToCountMap.getCount());
        }
        this.ingot = trading.getIngot();
    }

    public String getTradingId() {
        return tradingId;
    }

    public void setTradingId(String tradingId) {
        this.tradingId = tradingId;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public long getGold() {
        return gold;
    }

    public void setGold(long gold) {
        this.gold = gold;
    }

    public Map<String, Integer> getBackpackIdToCountMap() {
        return backpackIdToCountMap;
    }

    public void setBackpackIdToCountMap(Map<String, Integer> backpackIdToCountMap) {
        this.backpackIdToCountMap = backpackIdToCountMap;
    }

    public long getIngot() {
        return ingot;
    }

    public void setIngot(long ingot) {
        this.ingot = ingot;
    }

    public String getSenderId() {
        return senderId;
    }

    public void setSenderId(String senderId) {
        this.senderId = senderId;
    }

    public String getReceiverId() {
        return receiverId;
    }

    public void setReceiverId(String receiverId) {
        this.receiverId = receiverId;
    }

    @Override
    public String toString() {
        return "TradingVO{" +
                "tradingId='" + tradingId + '\'' +
                ", senderId='" + senderId + '\'' +
                ", receiverId='" + receiverId + '\'' +
                ", type=" + type +
                ", backpackIdToCountMap=" + backpackIdToCountMap +
                ", ingot=" + ingot +
                '}';
    }
}
